package com.nuaa.shopping.service.impl;

import com.nuaa.shopping.dao.ItemDao;
import com.nuaa.shopping.dao.OrderDao;
import com.nuaa.shopping.dao.impl.ItemDaoImpl;
import com.nuaa.shopping.dao.impl.OrderDaoImpl;
import com.nuaa.shopping.entity.Item;
import com.nuaa.shopping.entity.Order;
import com.nuaa.shopping.service.OrderService;

public class OrderServiceImpl  implements OrderService{

	private OrderDao orderDao = new OrderDaoImpl();
	private ItemDao itemDao = new ItemDaoImpl();
	
	@Override
	public void add(Order order) {
		// 向订单表中插入数据
		orderDao.insert(order);
		// 向订单明细表中插入数据
		for(Item item : order.getItems()){
			item.setOrder(order); // 设置item所属订单
			itemDao.insert(item);
		}
	}

}
